-
Notifications
You must be signed in to change notification settings - Fork 138
TEMP with initial value and provide default types for shader functions #2318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors shader code to use inline TEMP initialization with initial values, aiming to make the shader code more readable and easier to write. Key changes include:
- Replacing separate TEMP declarations and SET calls with inline initialization.
- Updating variable naming to a lower-case style in shader fragments.
- Adding explicit type information to math function calls in the shader DSL.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| korge/src/korlibs/korge/view/filter/DitheringFilter.kt | Updated index initialization and shader variable naming. |
| korge/src/korlibs/korge/view/fast/FSprites.kt | Adjusted baseSize computation and refined TEMP initialization for trigonometric values. |
| korge/src/korlibs/korge/render/RenderContext2DExt.kt | Replaced SET calls with inline TEMP initialization for shader variables. |
| korge-core/src/korlibs/korge/render/SDFShaders.kt | Inlined TEMP initializations in SDF functions for clarity. |
| korge-core/src/korlibs/graphics/shader/shaders.kt | Updated math functions and introduced a new TEMP overload with explicit type information. |
Comments suppressed due to low confidence (3)
korge/src/korlibs/korge/view/filter/DitheringFilter.kt:41
- Using inline initialization via TEMP improves clarity; please verify that the order of evaluation remains consistent with previous behavior.
val index = TEMP(float(x + y * width.lit))
korge-core/src/korlibs/graphics/shader/shaders.kt:493
- Providing explicit type information in math functions like sin, cos, and tan enhances type safety; please confirm that all downstream usages align with this update.
fun sin(angle: Operand): Operand = Func("sin", angle, type = angle.type)
korge-core/src/korlibs/graphics/shader/shaders.kt:769
- The new TEMP overload for inline initialization improves code readability; please verify its consistent adoption throughout the shader code.
fun TEMP(initialValue: Operand): Temp {
| fun atan(y_over_x: Operand): Operand = Func("atan", y_over_x) | ||
| fun asin(x: Operand): Operand = Func("asin", x, type = x.type) | ||
| fun acos(x: Operand): Operand = Func("acos", x, type = x.type) | ||
| fun atan(yOverX: Operand): Operand = Func("atan", yOverX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing type = yOverX.type?
soywiz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. But likely atan is missing the type = as the other functions
2c7acdb to
48ab7bc
Compare
|
Thanks! |
It seems for me like this change should make shaders more readable and easier to write